/**
 * https://leetcode.cn/problems/climbing-stairs/submissions/561788836/
 * 70. 爬楼梯
 * easy 陈贝纯 2024.09.05
 * 经典线性
 */

class Solution {
public:
    int climbStairs(int n) {
        int x=1;
        int y=2;
        if(n==1)
        return 1;
        for(int i=3;i<=n;++i){
            int z=x+y;
            x=y;
            y=z;
        }
        return y;
    }
};